package com.tpl.core.basedata.common.task;

import com.tpl.core.basedata.dao.TriggerTaskDao;
import com.tpl.core.common.Global;
import org.quartz.JobExecutionContext;
import org.quartz.Trigger;
import org.quartz.listeners.TriggerListenerSupport;


/**
 * 完成定时任务后的触发监听
 */
public class TaskFinishTriggerListener extends TriggerListenerSupport {

	private String name;
	private TriggerTaskDao triggerTaskDao=(TriggerTaskDao) Global.getContext().getBean("triggerTaskDao");
	
	public TaskFinishTriggerListener(String name) {
        this.name = name;
    }
	
	public String getName() {
		return name;
	}

	public void triggerComplete(Trigger trigger, JobExecutionContext context, int code) {
//		String curDate=DateUtil.getNowDate();
//        String triggerName = trigger.getName();
//        long id = Long.valueOf(triggerName.replace("trigger", ""));
//        TriggerTask task=triggerTaskDao.getTaskById(id);
//        triggerTaskDao.afterExcute(id,curDate);
//        if(task.getType()==0)
//        	TaskUtil.stopTask(id);
//    	ExecuteSql.execute("Insert Into bd_trigger_task_log(Id,execute_date,state,task_key) Values(seq_trigger_task_log.nextval,?,?,?)", curDate,code,task.getTaskKey());
//        getLog().info("updated job excute info");
    }

}
